<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <title>修改信息</title>
	<meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />
	<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
    <link rel="stylesheet" href="../css/font.css">
    <link rel="stylesheet" href="../css/xadmin.css">
    <script type="text/javascript" src="../js/jquery-3.2.1.js"></script>
    <script type="text/javascript" src="../lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="../js/xadmin.js"></script>
</head>

    <body>
        <div class="x-body">
            <form class="layui-form" lay-filter="formTest">
                 <div class="layui-form-item layui-hide">
                    <label for="userName" class="layui-form-label">
                        <span class="x-red">*</span>Id
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" id="userId" name="userId" lay-verify="required" autocomplete="off" value="1" class="layui-input" disabled="disabled">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label for="userName" class="layui-form-label">
                        <span class="x-red">*</span>账号
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" id="userName" name="userName" lay-verify="required" autocomplete="off" value="1" class="layui-input" disabled="disabled">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label for="presonName" class="layui-form-label">
                  <span class="x-red">*</span>姓名
              </label>
                    <div class="layui-input-inline">
                        <input type="text" id="presonName" name="presonName" lay-verify="required" autocomplete="off" value="1" class="layui-input">
                    </div>
                </div>

                <div class="layui-form-item">
                    <label for="personAge" class="layui-form-label">
                  年龄
              </label>
                    <div class="layui-input-inline">
                        <input type="text" id="personAge" name="personAge" lay-verify="number" autocomplete="off" value="" class="layui-input">
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label"><span class="x-red">*</span>性别</label>
                    <div class="layui-input-block">
                        <input type="radio" name="personSex" value="男" title="男" autocomplete="off" checked>
                        <input type="radio" name="personSex" value="女" title="女" autocomplete="off">
                    </div>
                </div>

                <div class="layui-form-item">
                    <label for="telephone" class="layui-form-label">
                  <span class="x-red">*</span>联系电话
              </label>
                    <div class="layui-input-inline">
                        <input type="text" id="telephone" name="telephone" lay-verify="phone" autocomplete="off" value="" class="layui-input">
                    </div>
                </div>

                <div class="layui-form-item">
                    <label for="L_repass" class="layui-form-label">
              </label>
                    <button class="layui-btn" lay-filter="go" lay-submit> 修改</button>
                    <button lay-filter="reset" class="layui-btn layui-btn-primary">重置</button>
                </div>
            </form>
        </div>
        <script>
        layui.use(['form', 'layer'], function() {
            
            var form = layui.form,
                layer = layui.layer;
                $.ajax({
                    type:"get",
                    url:"getOwnInfo",
                    cache:false,
                    async:true,
                    dataType: 'json',
                    success:function(result){
                        console.log(result);
                        form.val("formTest", result)
                    },
                    error:function(){
                        alert("e");
                    }
                    
                });
                form.on('button(reset)', function() {
                    form.val("formTest", result)
                });
                
                form.on('submit(go)', function(data) {
                    $.ajax({
                        type:"post",
                        url:"update",
                        async:true,
                        cache:false,
                        data: data.field,
                        success:function(result){
                        	if(result.msg == 'success'){
                                layer.alert("修改成功", {icon: 1},function () {
                                    var name = window.name; 
                                    if(name == ''||name == null||name == undefined){
                                        window.close();
                                    }else{
                                        var index = parent.layer.getFrameIndex(window.name);
                                        parent.layer.close(index);
                                    }
                                });
                            }else if(result.msg == 'error'){
                            	layer.alert("修改失败", {icon: 2});
                            }else{
                            	alert("error");
                            }
                        },
                        error:function(){
                            alert("e");
                        }
                    });
                    return false;
                });
        });
        </script>

    </body>

</html>